<?php
/** 
 * Theme Name : Real Estate
 * Description: The special theme for real-estate.
 * Author     : PhatPT
 * Version    : 0.1
 * License    : Apache License, Version 2.0
 * License URI: http://www.apache.org/licenses/LICENSE-2.0
 * Tags       : Real Estate
 * Text Domain: real-estate
 */
?>

<?php

/** Tell WordPress to run realEstate_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'realEstate_setup' );

if ( ! function_exists( 'realEstate_setup' ) ) {
    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * Note that this function is hooked into the after_setup_theme hook, which runs
     * before the init hook. The init hook is too late for some features, such as indicating
     * support post thumbnails.
     *
     * To override realEstate_setup() in a child theme, add your own realEstate_setup to your child theme's
     * functions.php file.
     *
     * @uses    register_nav_menus() To add support for navigation menus.
     * @since   Real Estate 0.1
     */
    function realEstate_setup() {
        // This theme uses wp_nav_menu() in one location.
        register_nav_menu( 'top-menu', __( 'Top Menu', 'Real Estate Menu') );
    }
}

add_action( 'widgets_init', 'realEstate_widgets_init' );
if( ! function_exists( 'realEstate_widgets_init' ) ) {
    /**
    * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
    *
    * To override realEstate_widgets_init() in a child theme, remove the action hook and add your own
    * function tied to the init hook.
    *
    * @since Real Estate 0.1
    * @uses register_sidebar
    */
    function realEstate_widgets_init() {
        register_sidebar( array(
                'name' => __( 'Right Sidebar Area', 'RealEstate' ),
                'id' => 'left-sidebar-area',
                'description' => __( 'The Right Sidebar Area', 'RealEstate' ),
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                'after_widget' => '</aside>',
                'before_title' => '<h3 class="widget-title">',
                'after_title' => '</h3>',
        ) );

        register_sidebar( array(
                'name' => __( 'Home Widget Area', 'RealEstate' ),
                'id' => 'home-widget-area',
                'description' => __( 'The Widget Area on homepage', 'RealEstate' ),
                'before_widget' => '<section id="%1$s" class="widget %2$s">',
                'after_widget' => '</section>',
                'before_title' => '<h3 class="widget-title">',
                'after_title' => '</h3>',
        ) );

        add_action( 'wp_enqueue_scripts', 'realEstate_scripts' );
    }
}

if (!function_exists('realEstate_scripts')) {
    /**
     * Register javascript files used in Real Estate
     */
    function realEstate_scripts() {
        // Don't allow loading jQuery default of wordpress
        wp_deregister_script('jquery');
        
        // Register script
        // Register jQuery version 1.8.0
        wp_register_script('jQuery-1.8.0', get_template_directory_uri() . '/js/jquery-1.8.0.js');
        
        // Register jquery.cycle.min.js
        wp_register_script('jQuery-cycle', get_template_directory_uri() . '/js/jquery.cycle.min.js');
        
        // Register javascript fragment to create slide content in home page
        wp_register_script('slide-gallery', get_template_directory_uri() . '/js/slide-gallery.js');
        
        // Add scripts to home page
        if (is_home()) {
            // Add jQuery version 1.8.0
            wp_enqueue_script('jQuery-1.8.0');
            
            // Add jquery.cycle.min.js
            wp_enqueue_script('jQuery-cycle');
            
            // Add javascript fragment to create slide content
            wp_enqueue_script('slide-gallery');
        }
    }
}

?>